home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / mgraph / sample.c < prev    next >
C/C++ Source or Header  |  1994-03-22  |  913b  |  58 lines

  1. /* Copyright 1994 Ralph Gonzalez */
  2.  
  3. /*
  4. *    FILE:        sample.c
  5. *    AUTHOR:        R. Gonzalez
  6. *    CREATED:    April 16, 1993
  7. *
  8. *    Sample application of mgraph/xgraph functions. Try substituting
  9. *    other colors from mgraph.h/xgraph.h in place of WHITE, if you're
  10. *    using a color monitor.
  11. */
  12.  
  13. # ifdef THINK_C
  14. # include "mgraph.h"
  15. # else
  16. # include "xgraph.h"
  17. # endif
  18. # include <stdlib.h>
  19.  
  20. main()
  21. {
  22.     double    x,
  23.         y,
  24.         old_x,
  25.         old_y;
  26.  
  27.     init_graphics();
  28.  
  29.     background_color(BLACK);
  30.     erase_graphics();
  31.     draw_line(-1.,-1.,1.,1.);
  32.     pen_color(WHITE);
  33.     draw_circle(0.,0.,1.);
  34.     pen_color(WHITE);
  35.     fill_circle(.5,.5,.2);
  36.  
  37.     get_mouse_location(&x,&y);
  38.     pen_color(WHITE);
  39.     fill_circle(x,y,.1);
  40.     old_x = x;
  41.     old_y = y;
  42.     while (!mouse_button_is_down())
  43.     {
  44.         get_mouse_location(&x,&y);
  45.         if (x!=old_x || y!=old_y)
  46.         {
  47.             pen_color(BLACK);
  48.             fill_circle(old_x,old_y,.1);
  49.             pen_color(WHITE);
  50.             fill_circle(x,y,.1);
  51.         }
  52.         old_x = x;
  53.         old_y = y;
  54.     }
  55. }
  56.  
  57.  
  58.